<%-- 
    Document   : sfxmpp
    Created on : 2016-7-22, 15:20:58
    Author     : cxhd
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
 <%@include file="../../link.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>收费项目与项目匹配</title>
    </head>
    <body ng-app="sfxmxm" ng-controller="ppManager">
        <style>
            body{background-color: #FFF}
        tr>th{ padding: 1px}
        tr:hover,tr.hover{background:#F2F2F2;}
        /*input{font-weight: bold}*/
    </style>
    <div >
   <!--<div class="col w-lg bg-light dk b-r bg-auto" id="aside" style="background-color: #ffffff;width: 100%">-->
        <!--仪器显示-->
          <div style="float: left;width:20%;">
                <div class="wrapper bg b-b" style="height: 50px;">
                    <!--<button class="btn btn-sm btn-success pull-right" ui-toggle-class="timeline-center" target=".timeline">Center</button>-->
                    <h4 class="m-n font-thin">收费项目浏览</h4>
                </div>
                <div class="wrapper" >
                    <form class="ng-pristine ng-valid">
                        <table  class="table table-striped table-bordered  table-hover"   >
                            <tr >
                                <th class="table-id">序号</th>
                                <th class="table-title">收费项目名</th>
                                <!--<th class="table-title">价格 </th>-->
                            </tr>
                            <tr  ng-repeat="cit in cits" ng-click="checkCharginitem(cit)">
                                <td>{{$index}}</td>
                                <td><div style="width:90px; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{cit.ITEMNAME}}</div></td>
                                <!--<td>{{cit.PRICE}}</td>-->
                            </tr>
                        </table>
                    </form>
                     <footer class="panel-heading">
                    <div class="row">
                        <div style="text-align: center" >                
                            <pagination ng-change="pageChanged1()" previous-text="上一页" next-text="下一页" first-text="第一页" last-text="最后一页" ng-model="data1.currentPage" items-per-page="data1.pageSize" total-items="data1.bigTotalItems" ng-model="data1.bigCurrentPage" max-size="data1.maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages"></pagination>

                        </div>
                    </div>
                </footer>
                </div>
        </div>
         <div style="float: left;width:30%;">
           <div class="wrapper bg b-b" style="height: 49px;padding: 1px;"  >
                    <!--<button class="btn btn-sm btn-success pull-right" ui-toggle-class="timeline-center" target=".timeline">Center</button>-->
                    <div style="margin-left:15%">  样本类型：
                    <select ng-model="PK1" ng-options="sam.PK as sam.SAMPLEDESCRIBE for sam in sams"   style="width: 90px" >
                        <option  value="">不选样本</option>
                    </select> 
                       
                    </div>
                    <div style="margin-left:15%">
                        项目代码：<input type="text" ng-model="TESTID" style="width:90px" /> 
                        <!--<button ng-click="getLisTestByT()"  >收索</button>-->
                       &nbsp;&nbsp; <button ng-click="getLisTestByT()"  class="btn btn-success btn-sm"><span class="fa fa-search"></span>&nbsp;&nbsp;搜索</button>
                    </div>
                    <!--<button ng-click="getLisTest()">收索</button>-->
                </div>
                <div class="wrapper" >
                    <form class="ng-pristine ng-valid">
                        <table  class="table table-striped table-bordered  table-hover"   >
                            <tr>
                                <th class="table-id"><input type="checkbox"></th>
                                <th class="table-title">项目代码</th>
                                <th class="table-title">项目名</th>
                                
                            </tr>
                            <tr  ng-repeat="test in tests" ng-click="checkTest($index)">
                                <td><input type="checkbox" ng-model="test.check"></td>
                                <td>{{test.TESTID}}</td>
                                <td>{{test.CHINESENAME}}</td>   
                            </tr>
                        </table>
                    </form>
                    <footer class="panel-heading">
                    <div class="row">
                        <div style="text-align: center" >                
                            <pagination ng-change="pageChanged()" previous-text="上一页" next-text="下一页" first-text="第一页" last-text="最后一页" ng-model="data.currentPage" items-per-page="data.pageSize" total-items="data.bigTotalItems" ng-model="data.bigCurrentPage" max-size="data.maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages"></pagination>

                        </div>
                    </div>
                </footer>
                </div>
              
            </div>

        <div style="float: left;width:44%;">
            <div class="wrapper bg b-b" style="height: 50px;">
                当前收费项目:<input type="text" ng-model="ITEMNAME"/>
                <button class="btn m-b-xs btn-sm btn-primary btn-addon" ng-click="addLisCharginitemTest()"><i class="fa fa-plus"></i>添加项目</button>
                 <!--<button class="btn m-b-xs btn-sm btn-primary btn-addon" ng-click="addTestPK()"><i class="fa fa-save"></i>addTestPK</button>-->
                
            </div>
            <div class="wrapper" >
                    <form class="ng-pristine ng-valid">
                        <table  class="table table-striped table-bordered  table-hover">
                            <tr>
                                <th class="table-id">收费项目名</th>
                                <th class="table-title">项目名</th>
                                <th class="table-title">项目代码</th>
                                <!--<th class="table-title">通道号</th>-->
                                <th class="table-title">操作</th>
                            </tr>
                            <tr  ng-repeat="citt in citts" >
                                <!--<td>{{ppdt.DEVICENAME}}</td>-->
                                <td>{{citt.ITEMID1}}</td>
                                <td>{{citt.TESTID1}}</td>
                                <td>{{citt.TESTID}}</td>
                                <td>
                                  <button ng-click="deleteLisCharginitemTest(citt)" class="btn btn-danger btn-xs"><span class="fa fa-bolt"></span>&nbsp;删除</button>  
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
        </div>
   <!--</div>-->
       
    </div>
    </body>
    
    <script>
         angular.module("sfxmxm",['baseModule', 'ui.bootstrap'])
               .controller("ppManager", function ($scope,$http,base) {
                   $scope.tests=[];
           $scope.cits=[];
           $scope.DEVICENAME="";
           
           $scope.data1 = {currentPage: 1};
                $scope.pageChanged1 = function () {
                   
                    $scope.getLisCharginitem();
                };
                $scope.data1.maxSize = 1;
                $scope.data1.bigTotalItems = 20;
                $scope.data1.bigCurrentPage= 1;
                $scope.data1.pageSize = 10;
                
             $scope.getLisCharginitem=function(){//收费项目显示
                 base.post("citemtest/getLisCharginitem",{pageSize: $scope.data1.pageSize, currentPage: $scope.data1.currentPage}).get(function(data){
                     console.log(data);
                     if(data){
                         $scope.cits=data.list;
                         $scope.data1.bigTotalItems = data.totalRow;
//                         $scope.$apply();
                     }
                 })
             }
             $scope.getLisCharginitem();
             $scope.getSamp=function(){//样本类型显示
                 base.post("citemtest/getLisSam").get(function(data){
                     if(data){
                         $scope.sams=data;
//                         $scope.$apply();
                     }
                 })
             }
             
              $scope.data = {currentPage: 1};
//                $scope.setPage = function (pageNo) {
//                    $scope.data.currentPage = pageNo;
//                };
                $scope.pageChanged = function () {
                    $scope.getLisTestByT();
                };
                $scope.data.maxSize = 1;
                $scope.data.bigTotalItems = 20;
                $scope.data.bigCurrentPage = 1;
                $scope.data.pageSize = 10;
             $scope.getSamp();
             $scope.getLisTest=function(){//通过样本类型筛选项目
                 base.post("citemtest/getLisTest",{PK:$scope.PK1,pageSize: $scope.data.pageSize, currentPage: $scope.data.currentPage}).get(function(data){
                     if(data){
                         $scope.tests=data.list;
                         $scope.data.bigTotalItems = data.totalRow;
//                         $scope.$apply();
                     }
                 })
             }
             $scope.TESTID="";
            $scope.getLisTestByT=function(){//通过拼音筛选项目
                 base.post("citemtest/getLisTestByPy",{PK:$scope.PK1,TESTID:$scope.TESTID,pageSize: $scope.data.pageSize, currentPage: $scope.data.currentPage}).get(function(data){
//                     console.log(data);
                     if(data){
                         $scope.tests=data.list;
                         $scope.data.bigTotalItems = data.totalRow;
//                         $scope.$apply();
                     }
                 })
             }
             $scope.getLisTestByT();
            $scope.checkCharginitem=function(tmp){
               
                $scope.PK=tmp.PK;
                $scope.ITEMID=tmp.ITEMID;
                $scope.ITEMNAME=tmp.ITEMNAME;
                $scope.ITEMPK=tmp.ITEMPK;
               $scope.getLisCharginitemTest();
            }
            $scope.checkTest=function(index){//点击行选择复选框
                if($scope.tests[index].check){
                $scope.tests[index].check = false;
            }else{
                $scope.tests[index].check = true; 
            }
            }
            $scope.checkT=[];
            $scope.addLisCharginitemTest=function(){
                if($scope.ITEMNAME==""){
                    alert("请选择匹配仪器");
                    return;
                }
                for(var i=0;i<$scope.tests.length;i++){//获取选中的项目
                    if($scope.tests[i].check){
                       $scope.checkT.push($scope.tests[i]); 
                    }
                }
                if($scope.checkT.length==0){
                    alert("请先为仪器选择项目在匹配");
                    return;
                }
                var checktes=JSON.stringify($scope.checkT);
                base.post("citemtest/saveLisCharginitemTest",{TESTS:checktes,ITEMID:$scope.ITEMID,PK:$scope.PK,ITEMPK:$scope.ITEMPK}).get(function(data){
                    if(data=='true'){                                                                         
                    $scope.getLisCharginitemTest();
                    // $scope.getLisCharginitem();
                    $scope.checkT=[];
                    }
                })
            }
            
            $scope.getLisCharginitemTest=function(){
                base.post("citemtest/getLisCharginitemTest",{ITEMID:$scope.ITEMID}).get(function(data){
                    if(data){
                        $scope.citts=data;
//                        $scope.$apply();
                    }
                })
            }
            $scope.getLisCharginitemTest();
            
            $scope.deleteLisCharginitemTest=function(tmp){
                
                base.post("citemtest/deleteLisCharginitemTest",{ITEMID:tmp.ITEMID,TESTID:tmp.TESTID}).get(function(data){
                    if(data=='true'){
                        
                      $scope.getLisCharginitemTest();
                      // $scope.getLisCharginitem();
                    }
                })
            }
           $scope.addTestPK=function(){
               base.post("citemtest/updateTestpk").get(function(data){
                   if(data){
                       alert("修改成功！");
                   }
               })
           }
 
             
         })
    </script>
</html>
